package oceanwiki.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @FileName TestJob
 * @Description
 * @Author Me
 * @date 2024-09-19
 **/

@Component
public class TestJob {
    private static final Logger LOG = LoggerFactory.getLogger(TestJob.class);

    //固定时间间隔
//    @Scheduled(fixedRate = 1000)
    public void simple() throws InterruptedException {
        SimpleDateFormat format = new SimpleDateFormat("mm:ss");
        String dataString = format.format(new Date());
        Thread.sleep(2000);
        LOG.info("每两秒执行一次：{}", dataString);
    }
}
